package cn.inyaa.admin.blog.controller;

import cn.inyaa.admin.blog.bean.InyaaType;
import cn.inyaa.admin.blog.service.InyaaTypeService;
import com.inyaa.base.bean.BaseResult;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/type")
@RequiredArgsConstructor
public class InyaaTypeController {

    private final InyaaTypeService inyaaTypeService;

    @PostMapping("/save")
    public BaseResult<String> save(@RequestBody InyaaType type) {
        inyaaTypeService.save(type);
        return BaseResult.success();
    }

    @GetMapping("/list")
    public BaseResult<List<InyaaType>> list() {
        return BaseResult.success(inyaaTypeService.findAll());
    }

    @PostMapping("/delete")
    public BaseResult<String> delete(@RequestBody InyaaType type) {
        inyaaTypeService.delete(type);
        return BaseResult.success();
    }
}
